Skip to content

fix: gate search tool registration on TAVILY_API_KEY presence#621

Merged
ngoiyaeric merged 1 commit into
QueueLab:mainfrom
itsautomata:fix/gate-search-tool-on-missing-keys
May 28, 2026
Merged

fix: gate search tool registration on TAVILY_API_KEY presence#621
ngoiyaeric merged 1 commit into
QueueLab:mainfrom
itsautomata:fix/gate-search-tool-on-missing-keys

Conversation

@itsautomata

@itsautomata itsautomata commented May 26, 2026

Copy link
Copy Markdown
Contributor

This PR matches the existing SERPER_API_KEY gating pattern (lib/agents/tools/index.tsx:31) for TAVILY_API_KEY, so the search tool is only registered when its required key is present. Previously the LLM would attempt search even on deployments without Tavily configured, surfacing "An error occurred while searching for..." in the UI on any search-y query without providing any further explanation.

Key Changes

  • lib/agents/tools/index.tsx: register search only when TAVILY_API_KEY is set, matching the existing pattern used for videoSearch + SERPER_API_KEY.
  • .env.local.example: add TAVILY_API_KEY entry with a comment noting the runtime behavior when unset.

Summary by CodeRabbit

  • Documentation

    • Added API key configuration guide for search functionality setup.
  • Chores

    • Search functionality is now optional and requires API key configuration to enable. If the API key is not configured, the search tool will be unavailable. All other application features remain fully functional and unaffected.

Review Change Stack

The search tool was registered unconditionally in getTools(), so the
LLM would attempt to call it even when TAVILY_API_KEY was unset. The
Tavily client then errored inside execute(), and the UI rendered "An
error occurred while searching for..." for any search-y query,
regardless of whether the deployment intended search to be enabled.

Match the existing SERPER_API_KEY pattern in the same file's
videoSearch registration: only register the tool when its required key
is present. The LLM then answers from its own knowledge for queries
that would have triggered search, with no misleading error card.

Also adds TAVILY_API_KEY to .env.local.example with a note documenting
the runtime behavior when unset.
@vercel

vercel Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

@itsautomata is attempting to deploy a commit to the QCX-MAIN Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR makes the Tavily search tool optional by gating its registration on the TAVILY_API_KEY environment variable. When the key is absent, the search tool is not registered, and other tools remain available. Configuration documentation is added to .env.local.example.

Changes

Optional Search Tool Integration

Layer / File(s) Summary
Environment configuration and conditional tool registration
.env.local.example, lib/agents/tools/index.tsx
Documentation added for TAVILY_API_KEY with a note that search is skipped if unset. The getTools function removes unconditional search registration and adds it conditionally only when TAVILY_API_KEY is present in the environment.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops through tools so neat,
With optional search—what a treat!
When keys align with what we need,
The search tool springs at rabbit speed.
No key, no search, just glide along,
The other tools stay right and strong. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: making the search tool registration conditional on TAVILY_API_KEY presence, which is the core objective of this fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel

vercel Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
qcx Ready Ready Preview, Comment May 28, 2026 7:46am

@ngoiyaeric ngoiyaeric merged commit 4e259ab into QueueLab:main May 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants